package com.java1412.order;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;

/**
 * @author java1412
 * @since 2024-01-15 15:50:21
 */
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients // 开启feign客户端
public class MallOrderApplication {
    public static void main(String[] args) {
        SpringApplication.run(MallOrderApplication.class, args);
    }

//    @Bean
//    @LoadBalanced   // 开启负载均衡策略
//    public RestTemplate restTemplate() {
//        return new RestTemplate();
//    }

    // 注册负载均衡策略
    @Bean
    public IRule loadbalancer() {
        return new RandomRule(); // 随机的负载均衡策略
    }
}
